package cn.tedu.boot112.controller;

import cn.tedu.boot112.entity.User;
import cn.tedu.boot112.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {
    @Autowired
    UserMapper mapper;
    @RequestMapping("/list")
    public List<User> selectList(){
        System.out.println("到达业务层方法");
        List<User> list=mapper.select();
        System.out.println(list.toString());
        return list;
    }
    @RequestMapping("/delete")
    public void delete(Integer id){
        System.out.println(id);
        System.out.println("到达业务层方法");
        mapper.delete(id);
    }
    @RequestMapping("/selectinid")
    public User selectinid(Integer id){
        System.out.println("到达selectinid业务层方法");
        User user=mapper.selectinid(id);
        return user;
    }
    @RequestMapping("/update")
    public void update(@RequestBody User user){
        System.out.println("到达update业务层方法");
        mapper.update(user);
    }
}
